package edu.cuit.svsp.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.cuit.svsp.entity.Complaint;
import edu.cuit.svsp.entity.Video;
import edu.cuit.svsp.mapper.ComplaintMapper;
import edu.cuit.svsp.request.ResPage;
import edu.cuit.svsp.service.ComplaintService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @className: ComplaintServiceImpl
 * @author: pjy
 * @description: 投诉服务层实现类
 * @date: 2024/7/9
 */
@Service
public class ComplaintServiceImpl implements ComplaintService {
    @Resource
    private ComplaintMapper complaintMapper;
    @Override
    public ResPage<List<Complaint>> list(Integer page,Integer size) {
        PageHelper.startPage(page, size);
        List<Complaint> list = complaintMapper.list();
        PageInfo<Complaint> pageInfo = new PageInfo<>(list);
        ResPage<List<Complaint>> resPage = new ResPage<>();
        resPage.setData(list);
        resPage.setPage(page);
        resPage.setSize(size);
        resPage.setTotal(pageInfo.getTotal());
        resPage.setPageTotal(pageInfo.getPages());
        return resPage;
    }

    @Override
    public boolean out(Integer id) {
        return complaintMapper.out(id);
    }
}
